#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "ak_common.h"
#include "ak_drv_ir.h"
#include "ak_misc.h"

/**
 * test_ircut_on_off - test ircut function.
 * @vi_handle[IN]: opened vi handle
 * @sec[IN]: interval time from off to on, second
 * @day_ctrl[IN]: day control level, [1, 4]
 * return:  0, sucess; -1, failed
 */
int test_ircut_on_off(void *vi_handle, int sec, int day_ctrl)
{
	ak_print_normal_ex("seconds: %d\n", sec);

	/* test interval time limit */
	if(sec > 8 || sec < 1) {
		ak_print_error_ex("argument invalid seconds: %d\n",  sec);
		return -1;
	}
	if(ak_drv_ir_init()< 0) {
		ak_print_error_ex("ak_drv_ir_init fail\n");
		return -1;
	}

	int ir_val = ak_drv_ir_get_input_level();
	/* reverse ircut */
	ak_misc_set_video_day_night(vi_handle, !ir_val, day_ctrl);
    sleep(sec);
	/* after sec second, reverse ircut */
	ak_misc_set_video_day_night(vi_handle, ir_val, day_ctrl);

	return 0;
}
